package com.test.ddaidai.main_project;

import java.util.List;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.test.ddaidai_android.activity.R;

public class ProgressAdapter extends BaseAdapter {

	List<Integer> list;
	LayoutInflater inflater;
	Context context;
	
	public ProgressAdapter(List<Integer> list,Context context) {
		super();
		// TODO Auto-generated constructor stub
		this.list = list;
		this.context = context;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		convertView = inflater.inflate(R.layout.item_list_financialmanage_project, null); 
		
		AssetManager assetManager = context.getAssets();
		
		Typeface typeFace =Typeface.createFromAsset(assetManager,"fonts/fzdbsjt.ttf");
		
//		Typeface typeFace = Typeface.createFromFile("@assets/fonts/fzdbst.ttf");
		
		RoundProgressBar progress = (RoundProgressBar) convertView.findViewById(R.id.circleProgressbar);
		progress.setProgress(list.get(position)+30);
		
		TextView tv_project_money = (TextView) convertView.findViewById(R.id.tv_project_money);
		tv_project_money.setTypeface(typeFace);
		
		
		TextView tv_project_money_percent = (TextView) convertView.findViewById(R.id.tv_project_money_percent);
		tv_project_money_percent.setTypeface(typeFace);
		
		TextView tv_project_money_time = (TextView) convertView.findViewById(R.id.tv_project_money_time);
		tv_project_money_time.setTypeface(typeFace);
		
		TextView main_project_state = (TextView) convertView.findViewById(R.id.main_project_state);
		main_project_state.setText("未开始"+position);
		
		if(position == 3){
			progress.setVisibility(View.GONE);
			convertView.findViewById(R.id.title_lay).setBackgroundResource(R.drawable.list_tv_item_fill_nor_selector);
			TextView main_project_title = (TextView) convertView.findViewById(R.id.main_project_title);
			main_project_title.setTextColor(Color.BLACK);
//			TextView main_project_state = (TextView) convertView.findViewById(R.id.main_project_state);
			main_project_state.setText("已满"+position);
			main_project_state.setTextColor(Color.BLACK);
			
			RoundImageView roundimageview = (RoundImageView) convertView.findViewById(R.id.roundImage_two_border);//R.drawable.icon5
			roundimageview.setImageDrawable(parent.getContext().getResources().getDrawable(R.drawable.icon5));
			TextView tv_state = (TextView) convertView.findViewById(R.id.tv_state);
			tv_state.setVisibility(View.VISIBLE);
		}
		
		return convertView;
	}
	
}
